How to Connect to WiFi from the Terminal in Ubuntu | 您所在的位置:网站首页 › linux terminal connect to wifi › How to Connect to WiFi from the Terminal in Ubuntu |
- Advertisement - Ubuntu is one of the easiest Linux distributions to use thanks to its powerful and well-designed graphic interface. But what happens on servers where there isn’t one? How do I connect to a Wifi network to have the Internet from the terminal? Well, that’s the objective of this post, to learn how to connect to Wifi from the terminal on Ubuntu. As I mentioned before, the great graphic interface of Ubuntu makes many tasks easy to do such as connecting to a network. However, in the case of servers with Ubuntu installed these do not have a graphical interface and you have to pull the terminal. But don’t worry it is much simpler than you might think. So, let’s get started. Learning how to connect to Wifi from terminal on Ubuntu 1.- How to get the name of the network interface of the Wifi cardOne of the first things we have to do is to find out the name of the network interface of the Wifi card. In case you already know it, you can skip this step, but if you don’t, you can use the following command: - Advertisement - ls /sys/class/netAnd in my case I get the following: enp6s0f0 the wlp5s0Usually, in the case of wireless cards, the name of the network interface starts with W. So in my case, it’s wlp5s0. If you don’t see one, it’s probably not connected or you have some driver problem. Now we can continue. 2.- The connecting to wifi processWhen no graphical interface is installed on Ubuntu, all network configuration is done by Netplan. That’s why the Netplan configuration file must be modified to establish the wifi connection. So, first create a backup of the file before editing it: sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bakNow we can edit it with the confidence of knowing that we have a backup done. The file is in a YAML format so you have to be careful with white spaces and editing in general. sudo nano /etc/netplan/50-cloud-init.yamlAnd, under the first configuration, add the basic information about the network you want to connect to as the SSID and the password: wifis: wlp5s0: dhcp4: true optional: true access-points: "SSID": password: "password"Then, save the changes and before applying them, make sure that the wpa_supplicant service is running to avoid problems: sudo systemctl start wpa_supplicant sudo systemctl status wpa_supplicant ● wpa_supplicant.service - WPA supplicant Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-10-08 12:12:28 -04; 58min ago Main PID: 963 (wpa_supplicant) Tasks: 1 (limit: 4414) CGroup: /system.slice/wpa_supplicant.service └─963 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicantWith the service running correctly, it now applies the changes in Netplan. sudo netplan generatesudo netplan applyAnd now hopefully you should be able to connect to the WiFi network. Alternative method: using nmtuiAlternatively, it is possible to use a tool called nmtui. This tool works in some systems where Network Manager manages the networks. This method is quite convenient to use when for some reason the Ubuntu graphical interface fails. To do this, just type the following command in the terminal: nmtuiAnd you will see the following screen where you can choose the Activate Connection option: ![]() Then, you will see a screen where you can see the connections available in the different network interfaces. Only, choose the WiFi network you want to connect to. ![]() Now you have to set the password in case the network is protected. ![]() In the end, you will connect to the network. You can check this because a “*” will appear next to the connected network. ![]() This method is quite easy and ideal for beginners. ConclusionIt may seem that connecting to Wifi from a terminal in Ubuntu is something quite complicated but thanks to this post, you have been able to verify that it is not. So this can help you a lot in both home and production servers. Also you can read: How to set a static ip address on Ubuntu 20.04? So, share this post and join our Telegram channel and our Facebook page. Also, buy us a coffee 😉 |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |